﻿using System;
using System.Threading;

namespace Chapter1.Recipe2
{
	class Program
	{
        static Thread t1 = null;
		static void Main(string[] args)
		{
			Thread t = new Thread(PrintNumbersWithDelay);
			t.Start();
            t1 = t;
			PrintNumbers();
            Console.ReadKey();
		}

		static void PrintNumbers()
		{
            Console.WriteLine("Starting PrintNumbers...");
			for (int i = 1; i < 18; i++)
			{
				Console.WriteLine(i);
			}
		}

		static void PrintNumbersWithDelay()
		{
            Console.WriteLine("Starting PrintNumbersWithDelay...");
			for (int i = 1; i < 18; i++)
			{
				Thread.Sleep(TimeSpan.FromSeconds(2));
                Console.Write(Thread.CurrentThread.ThreadState.ToString());
				Console.WriteLine(i);
			}
		}
	}
}
